#ifndef GRAPHICS_DIRECTX_RENDERER_H
#define GRAPHICS_DIRECTX_RENDERER_H

#include <d3d9.h>
#include <d3dx9.h>

#include "base/types.h"

#include "graphics/renderer.h"
#include "graphics/camera.h"
#include "graphics/result_codes.h"

namespace graphics {

class DirectxRenderer : public Renderer {
public:
    DirectxRenderer(HWND & window) : window_(window) {}

    int Initialize(const bool & fullscreen, const uint32 & width, const uint32 & height );
    int Shutdown();
    int Reset();

    int ToFullcreen();
    int ToWindowed();
    int ChangeResolution(int width, int height);

    int Render(const Camera * camera);

    cml::Handedness GetHandedness(){return cml::left_handed;}
    cml::ZClip GetZClip() {return cml::z_clip_zero;}
 
private:
    int InitializePresentParameters(const bool & fullscreen, const uint32 & width, const uint32 & height);

    int FindSupportedAdapterFormat();
    int FindSupportedStencilFormat();

    LPDIRECT3D9             instance_;   
    LPDIRECT3DDEVICE9       device_;

    
    D3DPRESENT_PARAMETERS   present_parameters_;    

    HWND &                  window_;
};

} //namespace

#endif //GRAPHICS_DIRECTX_RENDERER_H